#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a;i>b;--i)
#define LL long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; LL tmpLONGLONG;

int t,d;

bool judge(){
	vector<LL>v(4);
	v[0] = 1;
	int cnt = 1;
	XH(i , 2 , tmpLONGLONG+1){
		if(tmpLONGLONG%i == 0){
			if(i - v[cnt-1]<d){
				return false;
			}
			v[cnt++] = i;
		}
		if(cnt == 4){
			// XH(i , 0 , 4)printf("%lld ", v[i]);
			// printf("\n");
			return true;
		}
	}

	return false;
}

void solve(){
	while(1){
		if(judge()){
			break;
		}
		else tmpLONGLONG++;
	}
}

int main(){
	scanf("%d", &t);
	XH(i , 0 , t){
		scanf("%d", &d);
		tmpLONGLONG = 1 + 3*d;
		solve();
		printf("%lld\n", tmpLONGLONG);
	}
	
	return 0;
}